#include "wowgetway.h"
#include "ui_wowgetway.h"

wowGetway::wowGetway(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::wowGetway)
{
    ui->setupUi(this);
    //创建一个TCPSERVER对象
    m_TcpServer = new TcpServer();
    //设置网关服务端默认端口
    ui->ServerPort->setText("36000");
    //设置数据库默认用户名
    ui->MySql_UserName->setText("root");
    //设置数据库默认密码
    ui->MySql_Passwd->setText("root");
    //设置数据库默认IP
    ui->MySql_IP->setText("127.0.0.1");
    //设置数据库默认端口
    ui->MySql_Port->setText("3306");
    //设置账号库名称
    ui->auth_name->setText("auth");
    //设置角色库名称
    ui->charaters_name->setText("characters");
}

wowGetway::~wowGetway()
{
    delete ui;
    delete m_TcpServer;
    m_TcpServer = nullptr;
}

void wowGetway::Init()
{

    m_ServerPort = ui->ServerPort->text().toUShort();
    m_UserName = ui->MySql_UserName->text();
    m_Passwd=ui->MySql_Passwd->text();
    m_MySqlIp=ui->MySql_IP->text();
    m_MySqlPort=ui->MySql_Port->text();
    m_AuthName=ui->auth_name->text();
    m_CharName=ui->charaters_name->text();
}

quint16 wowGetway::GetServerPort()
{
    return m_ServerPort;
}




void wowGetway::on_OkButton_clicked()
{
    //初始化端口，数据库用户名，密码，库名等信息
    Init();
    //启动对象传入网关监听的端口
    m_TcpServer->NewTcpServer(m_ServerPort);
    //设置确认按钮不可用
    ui->OkButton->setDisabled(true);
}

